package view;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.KeyboardFocusManager;

import javax.swing.JFrame;
import javax.swing.UIManager;

import controle.AtalhosListener;



public class Janela extends JFrame {	
	
	public static void main(String[] args) {
		new Janela();
	}
	
	public Janela() {		
		this.configJanela();
		this.defineLayout();	
		this.setVisible(true);
	}
	
	private void configJanela() {
		KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(AtalhosListener.getInstancia());
		this.defineTema();
		this.setSize(900,600);
		this.setLocationRelativeTo(null);
		this.setTitle("Compilador");
		this.setFocusable(true);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
	}

	private void defineLayout() {
		this.setLayout(new BorderLayout());			
		this.add(getBarraBotoes(), BorderLayout.NORTH);		
		this.add(getBarraStatus(), BorderLayout.SOUTH);
		this.add(getPanelCentral(), BorderLayout.CENTER);
		
	}
	
	private Component getBarraBotoes() {
		return new PanelBotoes();
	}
	
	private Component getPanelCentral() {
		PanelCentral p = new PanelCentral();
		return p;
	}

	private Component getBarraStatus() {
		BarraStatus b = new BarraStatus();
		return b;
	}
	
	/**
	 * Configura o tema visual do programa.
	 * */
	private void defineTema() {
		try {  
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");               
        } catch (Exception e) {  
        	try {
				UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        	} catch (Exception e1) {
				e1.printStackTrace();
			} 
        }
	}
}
